<template>
  <div>
    <div class="chooseBackView">
      <div class="chooseView" @click="openClick">
        <p class="ellipsis1">{{selected.enterpriseName}}</p>
        <img class="iconView" :src="showGuidance ? '/web-hft-ee/static/img/university/pull_down.png' : '/web-hft-ee/static/img/university/pull_up.png' ">
      </div>
      <p class="totalBtn" @click="totalClick">汇总统计</p>
    </div>

    <van-popup :z-index="1000" v-model="showGuidance" position="top">
      <div style="height: 48px"></div>
      <div class="cardView">
        <div v-for="(el, idx) in list" class="itemView" @click="chooseClick(el)">
          <p class="itemLabel" :style="el.id === selected.id ? 'color: #1DA1F2' : 'color: #333333'">{{el.enterpriseName}}</p>
        </div>
      </div>
    </van-popup>

  </div>
</template>

<script>
  // import Vue from 'vue'
  import {Button, Popup} from 'vant'

  Vue.use(Button)
  Vue.use(Popup)

  export default {
    name: "UniversityChooseView",
    props: {
      selected: {
        type: Object,
        default: {},
      },
      list: {
        type: Array,
        default: [],
      }
    },
    data() {
      return {
        showGuidance: false,
      }
    },
    methods: {
      openClick() {
        this.showGuidance = !this.showGuidance
      },
      chooseClick(el) {
        this.showGuidance = false
        this.$emit('sendChoose', el)
      },
      totalClick() {

        this.$_router.push('/university/total')
      }
    }
  }
</script>

<style scoped>
  .chooseBackView {
    position: fixed;
    top: 0;
    z-index: 1200;
    box-sizing: border-box;
    padding: 0 16px;
    width: 100%;
    background-color: white;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: #DEDEDE 1px solid;
  }

  .chooseView {
    flex: 1;
    display: flex;
    align-items: flex-end;
  }

  .chooseView p {
    font-size: 18px;
    color: #333333;
    font-weight: bold;
  }

  .iconView {
    width: 10px;
    height: 10px;
    margin-left: 4px;
    padding-bottom: 4px;
  }

  .totalBtn {
    margin-left: 16px;
    color: #1DA1F2;
    font-size: 14px;
  }

  .cardView {
    width: 100%;
    max-height: 240px;
    background-color: white;
    overflow-y: scroll;
    overflow-x: hidden;
  }

  .itemView {
    border-bottom: #DEDEDE 1px solid;
    padding: 12px 16px;
  }

  .itemLabel {
    font-size: 14px;
  }
</style>
